<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title>已设置配送关系明细</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
 	
   
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>配送关系查询</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系查询</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
             <div class="input" >
                    <div class="textalign1">通用名：</div>
                    <div class="boxinput">
                        <input class="textinput" type="text" id="drugName" id="drugName" placeholder="通用名/<spring:message code="message.listForm.pinYinMa"/>"  maxlength="256" />
                    </div>
                    
					 <div class="textalign">项目名称：</div>
                    <div class="boxinput">
						<input type="text" class="textinput" id="projName" name="projName" placeholder="项目名称" />
                    </div>
            
                    <div class="textalign1">配送企业：</div>
                    <div class="boxinput">
                        <input class="textinput" id="compName" name="compName" type="text" placeholder="配送企业/<spring:message code="message.listForm.pinYinMa"/>"  maxlength="128" />
                    </div>
					
                    <div class="textalign1" >
                        <button   id="selectSee" type="button" class="btn btn-success btn-sm" onclick="search();">查 询</button>
                    </div>
             </div>
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="prowed2"></div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">

//绑定回车   id="selectSee"
$('#drugName,#drugCode,#projId,#compName,#area1,#area2,#area3').bind('keydown', function(event) {
    if (event.keyCode == "13") {
        $('#selectSee').click();
    }
}); 
$("#drugName").focus();//加载页面光标在第一个查询框内

$(function () {


			$("#area2").HNSelect({
            	parent_selector: "#area1",  url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID",defaultText: "<option value=''>请选择</option>",
                func: function () {
                    $("#area3").HNSelect({
                        parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                        		
                    });
                }
            });
jQuery("#gridlist").jqGrid({
	url: "${ctx}/baseGoods/getBaseDelByCompList.html",
    mtype: "POST",
	datatype: "json",
	autowidth: true,
   	colNames:['delRelId','配送区域','配送企业','采购价','商品编码','所属项目','药品编码','通用名','剂型','规格','转换系数','单位','材质','项目'],

   	colModel:[
		{name:'delRelId',index:'delRelId',key:true,hidden:true, width:0, sortable:false},
		{name:'areaName',index:'areaName',align:"center", width:70,sortable:false, sorttype:false,hidden:true},
   		{name:'delCompName',index:'compName', width:190,sortable:false, sorttype:false},
        {name:'proPriceLimit',index:'proPriceLimit',width:80,align:"right",sortable:false,
            formatter:function(cellvalue, options, row){ 
                return formatAmount(cellvalue, options, row);
            }
        },
   		{name:'goodsCode',index:'goodsCode', width:100, align:"center", sortable:false,hidden:true},
		{name:'projName',index:'projName', width:160, sortable:false,hidden:true},
		{name:'drugCode', width: 100 , align:"center", hidden:true,sortable:false},
   		{name:'qualityspecName',index:'qualityspecName', width:140,align:"left", sortable:false},
   		{name:'formName',index:'formName', width:80, align:"center", sortable:false},
   		{name:'specName',index:'specName', width:80, align:"left", sortable:false},
   		{name:'factor',index:'factor', width:80, align:"left",sortable:false},
   		{name:'unitName',index:'unit', width:40, align:"center",sortable:false},
   		{name:'materialName',index:'unit', width:80, align:"center",sortable:false,hidden:true},
   		{name:'projName',index:'projName', width:120, align:"center",sortable:false}
   		
   	],
	 rowNum: 20,
     rowList: [10, 20, 50,100],
     rownumbers: true,
     multiselect: false,
     pager: "#prowed2",
     viewrecords: true,
     caption: "配送关系查询列表",
     gridComplete:function(){
         //序号列宽度自适应（参数为jqgridID）
         autoRNWidth("gridlist");
         //数据只有一条时默认选中（参数为jqgridID）
         selectByOneData("gridlist");
     },
     jsonReader: {
         repeatitems: false,
         id: "delRelId"
     }
   	
});
	
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	$("#gridlist").jqGrid("setGridHeight", create());
	$(window).trigger("resize");
	
	$("#projId").HNSelect({
        url: "${pageContext.request.contextPath}/selectController/getProjByProdCompId.html", data: { ID: '' },defaultselect:'${form.patternType}',  defaultText: "<option value=''>请选择</option>",
    });
});

function search() {
	var goodsCode = $.trim($("#goodsCode").val());
	var drugCode = $.trim($("#drugCode").val());
	var drugName = $.trim($("#drugName").val());
	var projName = $.trim($("#projName").val());
	var compName = $.trim($("#compName").val());
	var area2 = $.trim($("#area2").val());
	var area3 = $.trim($("#area3").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"goodsCode":goodsCode,
        		"drugCode":drugCode,
        		"drugName":drugName,
        		"projName":projName,
        		"compName":compName,
        		"area2":area2,
        		"area3":area3},
        		page:1
    }).trigger("reloadGrid"); //重新载入  
}
function removeDel() {
   	//获取选中的ID及对应的名字（参数:jqgridId,名字列名，状态列名，当前操作即列表中显示的值），返回infos[0]是ID串，infos[1]是名字串
  var infos = batchSwitchStatus("gridlist","qualityspecName","delCompName","解除配送关系","药品");
  if ( !(infos instanceof Array)){
   		return;
  }
  $.HN.message.confirm('确定为解除所选配送关系吗？', '', '').on(function (e) {
      if (e) {
      	$.ajax({
              url:"${pageContext.request.contextPath}/baseGoods/removeDel.html",//action地址
              data: {param:infos[0],status:"3"},//传值
              type: "post",//执行方式get or post 默认以post方式执行
              dataType:"json",
              success: function (result) {//执行成功后 提示
                  if (result.success){
                  	top.$.HN.message.alert("成功解除"+infos[0].split(",").length+"个配送关系！","", "success");
                  	search($("#gridlist").getGridParam("page"));
                 } else {
              	   top.$.HN.message.alert("操作失败！！","", "error");
                 } 
              }
          });
      }
  });
}
    
	
    
</script>
</body>
</html>